<?php $reportModel = new Admin_Model_Report() ?>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span3"><?php echo $this->partial('report/menu.phtml') ?></div>
        <div class="span9">
            <div class="wrap">
                <div id="main-content">
                    <div class="top-link"><a href="<?php echo $this->baseUrl('admin/civility/new') ?>/?num_vente=<?php echo $this->numVente ?>">Ajout</a></div>
                    <table>
                        <thead>
                            <tr>
                                <th align="center">N° Client</th>
                                <th align="center">Client</th>
                                <th align="center">Montant dû</th>
                                <th align="center">Editer</th>
                                <th class="td-head">Voir acompte(s)</th>
                                <th align="right">Relevé<br />achat</th>
                                <th align="center">Décompte<br />déposant</th>
                            </tr>
                        </thead>
                        <tfoot>
                            <tr>
                                <td colspan="10">
                                    <?php if(count($this->paginator) > 1) :?>
                                        <?php echo $this->paginationControl($this->paginator, 'Sliding', '_pagination.phtml', array('num_vente' => $this->numVente)); ?>
                                    <?php endif;?>
                                    <!-- End .pagination -->

                                    <div class="clear"></div>
                               </td>
                            </tr>
                        </tfoot>
                        <tbody style="width:100%">
                        <?php  foreach($this->paginator as $row): ?>
                            <tr>
                                <td valign="top"><?php echo (int) $row['num_client'] ?></td>
                                <td valign="top"><?php echo stripslashes($row['prenom']) ?>&nbsp;<?php echo stripslashes($row['nom']) ?></td>
                                <?php $reste = $row['montant'] - $reportModel->getMontantAcompte($row['p_releve']) ?>
                                <td valign="top"><?php echo number_format($reste,2,",",".") . " €"; ?></td>
                                <td valign="top">
                                    <a href="<?php echo $this->baseUrl('admin/report/releve-edit') ?>/?id=<?php echo $row['p_releve'] ?>&numcli=<?php echo (int) $row['num_client'] ?>&num_vente=<?php echo $this->numVente ?>">
                                        <?php echo $this->image()->getEdit() ?>
                                    </a>
                                </td>
                                <?php $countAcompte = $reportModel->countReleveAcompte($row['p_releve']) ?>
                                <td valign="top">
                                    <?php if ($countAcompte > 0) : ?>
                                    <a href="<?php echo $this->baseUrl('admin/report/releve-acompte') ?>/?id=<?php echo $row['p_releve'] ?>&numcli=<?php echo (int) $row['num_client'] ?>&num_vente=<?php echo $this->numVente ?>">
                                        <?php echo $this->image()->getCalculate() ?>
                                    </a>
                                    <?php endif ?>
                                </td>
                                <td valign="top" class="a-center">
                                    <a href="javascript:void(0)">
                                        <?php echo $this->image()->getPdf() ?>
                                    </a>
                                </td>
                                <td valign="top" class="a-center">
                                    <?php if ($row['vendeur'] == 1) : ?>
                                        <?php $countDeposant = $reportModel->countDeposant($row['p_clients'], $this->numVente) ?>
                                        <?php if ($countDeposant > 0) : ?>
                                            <a href="javascript:void(0)">
                                                <?php echo $this->image()->getPdf() ?>
                                            </a>
                                        <?php endif ?>
                                    <?php endif ?>
                                </td>
                            </tr>
                        <?php endforeach ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>